package com.choupin.choupin.controller;


import com.choupin.choupin.entity.JsonResult;
import com.choupin.choupin.service.IUserService;
import com.choupin.choupin.service.exception.LoginErrorxception;
import com.choupin.choupin.service.impl.UserServiceImpl;
import com.choupin.choupin.utils.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/error")
public class ErrorController extends BaseController {

    @Autowired
    RedisUtils redisUtils;

    @Autowired
    IUserService iUserService;

    /* 该方法用户实现登录拦截功能
    * */
    @CrossOrigin
    @PostMapping("/loginerror")
    public JsonResult<Void> loginerror(@RequestBody Map<String,Object> data){
        //获取前端传来的手机号
        String phone= (String) data.get("phone");
        System.out.println("前端传来的手机号："+phone);
       JsonResult<Void> jsonResult=new JsonResult<>();
        iUserService.loginInterceptor(phone);
       jsonResult.setState(SUCCESS);
       return jsonResult;
    }


}
